package com.whz.governance.redislimiter.tool;

import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.data.redis.core.script.RedisScript;

import java.util.List;

/**
 * @author whz
 */
public class RedisScriptExecutor<T> {

    private final StringRedisTemplate stringRedisTemplate;
    private final RedisScript<T> redisScript;

    public RedisScriptExecutor(final RedisScript<T> redisScript, final StringRedisTemplate stringRedisTemplate) {
        this.stringRedisTemplate = stringRedisTemplate;
        this.redisScript = redisScript;
    }

    public T executeScript(List<String> keys, Object... args) {
        return stringRedisTemplate.execute(redisScript, keys, args);
    }
}